const express = require('express');

//const reviewController = require('./../controllers/reviewController');
const reviewRouter = require('./../routes/reviewRoutes')
const tourController = require('./../controllers/tourController');
// router.param('id',tourController.checkId)
const authController = require('./../controllers/authController');
const router = express.Router();
router.use('/:tourId/reviews',reviewRouter)

router.route('/get-monthly-plan/:year').get(tourController.getMonthlyPlan);
router.route('/get-tourStats').get(tourController.getTourStats);
router
  .route('/top-5-cheap')
  .get(tourController.aliasTopTours, tourController.getAllTours);
router
  .route('/')
  .get(authController.protect, tourController.getAllTours)
  .post(tourController.createTour);
router
  .route('/:id')
  .get(tourController.getTour)
  .patch(tourController.updateTour)
  .delete(
    authController.protect,
    authController.restrictTo('admin', 'lead-guide'),
    tourController.deleteTour
  );

//Create a checkbox middleware

// P0ST /tour/234fad4/reviews
// GET /tour/234fad4/reviews
//GET /tour/234fad4/reviews/94887fda
// router
//   .route('/:tourId/reviews')
//   .post(
//     authController.protect,
//     authController.restrictTo('user'),
//     reviewController.createReview
//   );


module.exports = router;
